//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<CTechnique10.h>
///	@path	~/src/graphics/dx10/
///	@date	2008/12/20
///	@desc	.

#pragma once

#include "xeres.h"

#include "graphics/IEffect.h"
#include "graphics/ITechnique.h"
#include "graphics/IShaderVariable.h"
#include "graphics/dx10/CDevice10.h"
#include "graphics/dx10/CEffect10.h"

namespace xeres {
	
	/*!
		\class	CTechnique10
		\brief
	*/
	class CTechnique10 : public ITechnique
	{
	public:

		/// \ctor
		CTechnique10( RefWeak<IEffect> effect , ID3D10EffectTechnique * technique );

		/// \dtor
		virtual ~CTechnique10( void );

		DECL_IOBJECT_CLASS( CTechnique10 , ITechnique );

	public:

	//@ interface

		/// \impl
		virtual size_t GetVariableCount( void );

		/// \impl
		virtual RefPass< IShaderVariable > GetVariableByIndex( size_t index );

		/// \impl
		virtual RefPass< IShaderVariable > GetVariableByName( const AString& name );

		/// \impl
		virtual RefPass< IShaderVariable > GetVariableBySemantic( const AString& semantic );

		/// \impl
		virtual const WString& GetName( void );

		/// \impl
		virtual size_t GetPassCount( void );

		/// \impl
		virtual RefWeak<IEffect> GetEffect( void );

		/// \impl
		virtual void Begin( uint pass , RenderContext& rc );

		/// \impl
		virtual void End( uint& pass , RenderContext& rc );

		/// \impl
		virtual void Draw( RenderContext& rc , RefWeak<IGeometry> geometry );

	public:

		// local methods

		/*! 
			\brief		Get input signature.
		*/
		const void * GetSignature( void ) const { return m_inputSignature; }

		/*! 
			\brief		Get signature size.
		*/
		size_t GetSignatureSize( void ) const { return m_signatureSize; }

	private:

		//@ friend
		friend class CEffect10;

	//@ data

		// effect
		Ref<IEffect>			m_effect;

		// technique interface
		ID3D10EffectTechnique *	m_pTechnique;

		// technique desc
		D3D10_TECHNIQUE_DESC	m_desc;

		// technique signature
		const void *			m_inputSignature;
		size_t					m_signatureSize;

		// technique name
		WString					m_name;
	};

} // namespace xeres
